<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Tymon\JWTAuth\Contracts\JWTSubject;

/**
 * App\Models\AdminUsers
 *
 * @property int $id
 * @property string|null $account
 * @property string $name
 * @property string|null $phone
 * @property string|null $email
 * @property string $password
 * @property string|null $salt
 * @property string $head_img 头像
 * @property string|null $remember_token
 * @property int|null $role_id 角色id
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property string|null $deleted_at
 * @property int $group_id 组织架构
 * @property int|null $is_valid 是否禁用
 * @property string|null $menu_id 功能ID集合，逗号隔开
 * @property string|null $routes_id 路由集合
 * @property int|null $is_open 开放权限
 * @property string|null $last_login_time 上次登录时间
 * @property string|null $now_login_time 本次登录时间
 * @property string|null $last_login_ip 上次登录密码
 * @property string|null $now_login_ip 本次登录IP
 * @property int|null $sms_login 是否开启短信验证登录 1开启 0不开启
 * @property int $user_type 1、系统管理员 2.普通管理员
 * @property int $created_by_admin_id 创建人
 * @property int $updated_by_admin_id 更新人
 * @property int|null $temp_group_id 临时组织（用于系统超级管理员切换组织）
 * @property string $guards 区分是哪个管理端
 * @property-read \App\Models\AdminGroupModel|null $myGroup
 * @property-read \Illuminate\Notifications\DatabaseNotificationCollection<int, \Illuminate\Notifications\DatabaseNotification> $notifications
 * @property-read int|null $notifications_count
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers query()
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereAccount($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereCreatedByAdminId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereEmail($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereGroupId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereGuards($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereHeadImg($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereIsOpen($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereIsValid($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereLastLoginIp($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereLastLoginTime($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereMenuId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereNowLoginIp($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereNowLoginTime($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers wherePassword($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers wherePhone($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereRememberToken($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereRoleId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereRoutesId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereSalt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereSmsLogin($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereTempGroupId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereUpdatedByAdminId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminUsers whereUserType($value)
 * @mixin \Eloquent
 */
class AdminUsers extends Authenticatable implements JWTSubject
{
    use HasFactory, Notifiable;

    public $table = 'admin_user';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'account',
        'realname',
        'mobile',
        'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password',
        'remember_token',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];

    public function getJWTIdentifier()
    {
        return $this->getKey();
    }

    public function getJWTCustomClaims()
    {
        return [
//            'role_id'=>$this->getAttribute('role_id'),
//            'group_id'=>$this->getAttribute('group_id'),
        ];
    }

}
